package com.example.life;


import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

public class BeanPost implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {

        System.out.println("before:"+bean+"===>>>"+beanName);
        return BeanPostProcessor.super.postProcessBeforeInitialization(bean, beanName);
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {

        System.out.println("after:"+bean+"===>>"+beanName);
        /**
         * d对一个已经初始化之后的bean，进行再次修改
         */
        if("beanLife".equals(beanName)){
            BeanLife b= (BeanLife) bean;
            b.setId(900);
        }
        return null;
    }
}
